package graph_algorithms;

/**
 * author :  apurv verma
 * email  :  dapurv5@gmail.com
 */


import java.io.*;


public class Graph implements Serializable {
	
	boolean G[][];
	int n;
	double D[][];
	
	/*
	 * THE edgeLength[][] MATRIX NEEDS TO BE GIVEN IN THE FOLLOWING FORMAT.
	 *  0	1	5	-1	-1
	 *  1	0  -1	 1	 1
	 *  5  -1   0	 1   1
	 * -1	1	1	 0	-1
	 * -1	3	1	-1	 0
	 * 
	 * THE ABOVE REPRESENTS A GRAPH WITH 5 VERTICES i.e. n=5
	 * THE VERTICES WHICH ARE NOT CONNECTED SHOULD HAVE A -1 PLACED AT THAT EDGE.
	 */
	
	public Graph(double edgeLength[][]){
		
		n=edgeLength[0].length;
		G=new boolean[n][n];
		D=new double[n][n];
		
		
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(edgeLength[i][j]>0){
					D[i][j]=edgeLength[i][j];
					G[i][j]=true;
				}
				else if(edgeLength[i][j]<0){
					D[i][j]=Double.MAX_VALUE;
					G[i][j]=false;
				}
				else{
					D[i][j]=0;
					G[i][j]=false;
				}
			}
		}
	}
	
	

}
